﻿using Nop.Core.Domain.Directory;
using System.Data.Entity.ModelConfiguration;

namespace Nop.Data.Mapping.Directory
{
    public class RegionMap : EntityTypeConfiguration<Region>
    {
        public RegionMap()
        {
            this.ToTable("Region");
            this.HasKey(d => d.Id);

            this.Property(d => d.Name)
                .IsRequired()
                .HasMaxLength(1000);

            this.Property(d => d.DisplayOrder)
                .IsRequired();

            this.HasMany(d => d.Districts)
                .WithRequired(d => d.Region)
                .HasForeignKey(d => d.RegionId);
        }
    }
}
